﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace ChoJu.Converters.Collection
{
    public class PartConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var part = value?.ToString();

            if (part == "下部" & parameter.ToString() == "1")
                return true;
            else if (part == "中部" & parameter.ToString() == "2")
                return true;
            else if (part == "上部" & parameter.ToString() == "3")
                return true;

            return false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool isChecked = (bool)value;
            if (!isChecked)
                return null;

            switch (parameter)
            {
                case "1": return "下部";
                case "2": return "中部";
                case "3": return "上部";
                default:return "";
            }

        }
    }
}
